home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / +system+ / tools / gui / bgui.lha / bgui / Examples / Source / DemoCode.h < prev    next >
C/C++ Source or Header  |  2000-02-27  |  3KB  |  153 lines

  1. /*
  2.  * @(#) $Header: /cvsroot/bgui/examples/Attic/DemoCode.h,v 1.1.2.2 1999/02/19 05:03:50 mlemos Exp $
  3.  *
  4.  * DemoCode.h
  5.  *
  6.  * (C) Copyright 1998 Manuel Lemos.
  7.  * (C) Copyright 1995 Jaba Development.
  8.  * (C) Copyright 1995 Jan van den Baard.
  9.  * All Rights Reserved.
  10.  *
  11.  * $Log: DemoCode.h,v $
  12.  * Revision 1.1.2.2  1999/02/19 05:03:50  mlemos
  13.  * Added support to build with Storm C.
  14.  *
  15.  * Revision 1.1.2.1  1998/02/28 17:45:49  mlemos
  16.  * Ian sources
  17.  *
  18.  *
  19.  */
  20.  
  21. #include <exec/types.h>
  22. #include <exec/memory.h>
  23. #include <dos/dos.h>
  24. #include <libraries/gadtools.h>
  25. #include <libraries/bgui.h>
  26. #include <libraries/bgui_macros.h>
  27. #include <intuition/sghooks.h>
  28. #ifndef __STORM__
  29. #include <graphics/gfxmacros.h>
  30. #endif
  31. #include <workbench/workbench.h>
  32. #include <workbench/startup.h>
  33.  
  34. #include <clib/alib_protos.h>
  35.  
  36. #include <proto/exec.h>
  37. #include <proto/intuition.h>
  38. #include <proto/dos.h>
  39. #include <proto/bgui.h>
  40. #include <proto/graphics.h>
  41. #include <proto/diskfont.h>
  42. #include <proto/utility.h>
  43.  
  44. #ifdef __STORM__
  45. #include <graphics/gfxmacros.h>
  46. #endif
  47.  
  48. #include <stdlib.h>
  49.  
  50. #ifdef _DCC
  51. #define SAVEDS __geta4
  52. #define ASM
  53. #define REG(x) __ ## x
  54. #define CHIP(t) __chip t
  55. #elif __STORM__
  56. #define CHIP(t) __chip t
  57. #ifndef SAVEDS
  58. #define SAVEDS  __saveds
  59. #endif
  60. #ifndef ASM
  61. #define ASM
  62. #endif
  63. #ifndef REG
  64. #define REG(x) register __ ## x
  65. #endif
  66. #else
  67. #define SAVEDS __saveds
  68. #define ASM __asm
  69. #define REG(x) register __ ## x
  70. #define CHIP(t) t chip
  71. #endif
  72.  
  73. /*
  74.  * The entry point of all demo programs.
  75.  */
  76. extern VOID StartDemo( void );
  77.  
  78. /*
  79.  * Output file handle and BGUI
  80.  * library base.
  81.  */
  82. BPTR     StdOut;
  83. struct Library *BGUIBase;
  84.  
  85. /*
  86.  * Output text to the CLI or Workbench console.
  87.  */
  88. VOID Tell( UBYTE *fstr, ... )
  89. {
  90.    if ( StdOut ) VFPrintf( StdOut, fstr, ( ULONG * )&fstr + 1 );
  91. }
  92.  
  93. /*
  94.  * Main entry point.
  95.  */
  96. int main( int argc, char **argv )
  97. {
  98.    struct Process       *this_task = ( struct Process * )FindTask( NULL );
  99.    BOOL            is_wb = FALSE;
  100.  
  101.    if ( this_task->pr_CLI )
  102.       /*
  103.        * Started from the CLI. Simply pickup
  104.        * the CLI output handle.
  105.        */
  106.       StdOut = Output();
  107.    else {
  108.       /*
  109.        * Workbench startup. Open a console
  110.        * for output.
  111.        */
  112.       StdOut = Open( "CON:10/10/500/100/BGUI Demo Output/WAIT/AUTO", MODE_NEWFILE );
  113.       is_wb = TRUE;
  114.    }
  115.  
  116.    /*
  117.     * Open BGUI.
  118.     */
  119.    if ( BGUIBase = OpenLibrary( BGUINAME, BGUIVERSION )) {
  120.       /*
  121.        * Run the demo.
  122.        */
  123.       StartDemo();
  124.       CloseLibrary( BGUIBase );
  125.    } else
  126.       Tell( "Unable to open %s version %ld\n", BGUINAME, BGUIVERSION );
  127.  
  128.    /*
  129.     * Close console if ran from
  130.     * the workbench.
  131.     */
  132.    if ( is_wb ) {
  133.       if ( StdOut ) Close( StdOut );
  134.    }
  135.  
  136.    return( 0 );
  137. }
  138.  
  139. /*
  140.  * DICE stub which simply calls
  141.  * main() when run from the
  142.  * workbench.
  143.  */
  144. #if _DCC || __STORM__
  145. int wbmain( struct WBStartup *wbs )
  146. {
  147.    return( main( NULL, 0 ));
  148. }
  149. #endif
  150.  
  151. #define FuzzButton(label,id) ButtonObject, LAB_Label, label, LAB_Underscore, '_',\
  152.    GA_ID, id, FuzzButtonFrame, EndObject
  153.